for i in [0..5]
    console.log "Hello #{i}"
##################################################################
## Functions are defined by an optional list of parameters in parentheses, an arrow, and the function body
square = (x) -> x * x  # square = function(x) {return x * x;};
cube = (x) -> square(x) * x  # cube = function(x) {return square(x) * x;};
console.log square(5), cube(5)  # 25 125
fill = (container, liquid = "coffee") -> "Filling the #{container} with #{liquid}..."  # 参数有默认值
console.log fill('jrp', 'dr')
##################################################################
## Objects and Arrays
song = ["do", "re", "mi", "fa", "so"]  # song = ["do", "re", "mi", "fa", "so"];
singers = {Jagger: "Rock", Elvis: "Roll"}
bitlist = [
    1, 0, 1
    0, 0, 1
    1, 1, 0
]
kids =
brother:
    name: "Max"
    age: 11
sister:
    name: "Ida"
    age: 9
##################################################################
## 自动为 class 等保留字添加 ""
tmp = class: 'active'
console.log tmp.class
##################################################################
## CoffeeScript has a shortcut for creating objects when you want the key to be set with a variable of the same name.
name = "Michelangelo"
mask = "orange"
weapon = "nunchuks"
turtle = {name, mask, weapon}  # turtle = {name: name, mask: mask, weapon: weapon};
console.log "#{turtle.name} wears an #{turtle.mask} mask. Watch out for his #{turtle.weapon}!"
##################################################################
## Everything is an Expression
six = (one = 1) + (two = 2) + (three = 3)  # 可以边用边赋值
##################################################################
## Operators and Aliases
# is ===; isnt !==; not !; and &&; or ||;
# of in; in no JS equivalent
# a ** b Math.pow(a, b); a // b Math.floor(a / b); a %% b (a % b + b) % b
##################################################################
## Switch/When/Else
switch 3
  when 1 then console.log 'jrp'
  when 2, 3
    if 'str' is 'str'
        console.log 'jrp dr'  # 碰到匹配的就会停止
  when 3 then console.log 'dr'
  else console.log 'end'
